/*------------------------------------------------------------------------
* Seedset-generator
* $Id$
* Copyright (c) 2008 Regents of the University of Minnesota.
* All Rights Reserved by the Regents of the University of Minnesota.
* This file contains Original Code and/or Modifications of Original
* Code as defined in the MAGNET Public Source License, which is
* available at http://www.cs.umn.edu/magnet/source_license_v1.txt.
* You may not use this file except in compliance with the License.
*------------------------------------------------------------------------
*/

package edu.umn.cs.tac.seedsetgen;

import java.util.Arrays;

public class SeedParameter
{
    // Seed Parameter information
    private String name;
    private String description;
    private boolean parameterGroup; //is this actually a collection of parameters?
    int controlType; // 0=random, 1=controlled, -1=partially controlled
    private long seed;

    public static int RANDOM_TYPE = 0;
    public static int CONTROLLED_TYPE = 1;
    public static int PARTIAL_TYPE = -1;

    // Constructors
    public SeedParameter()
    {
        name = "Generic Seed Name";
        description = "Generic Seed Description";
        seed = 0;
    }

    public SeedParameter(String n)
    {
        name = n;
        description = "Generic Seed Description";
        parameterGroup = false;
        controlType = 0;
        seed = 0;
    }

    public SeedParameter(String n, boolean pGroup)
    {
        name = n;
        description = "Generic Seed Description";
        parameterGroup = pGroup;
        controlType = 0;
        seed = 0;
    }

    public void setControlType(int type)
    {
        controlType = type;
    }

    public int getControlType()
    {
        return controlType;
    }

    public boolean isRandom()
    {
        return (seed == ((long) 0));
    }

    //return type as a meaningful string
    public String getControlTypeAsString()
    {
        String s;
        if (controlType == 0)
            s = "Random";
        else if (controlType == 1)
            s = "Controlled";
        else 
            s = "Partially Controlled";
        return s;
    }

    public boolean getParameterGroup()
    {
        return parameterGroup;
    }

    public String getParameterGroupAsString()
    {
        String s;
        if (parameterGroup==true) 
            s = "Group of Parameters";
        else
            s = "Single Parameter";
        return s;
    }

    public void setParameterGroup(boolean pGroup)
    {
        parameterGroup = pGroup;
    }

    // Accessor functions
    public long getSeed()
    {
        return seed;
    }

    public String getName()
    {
        return name;
    }

    public String getDescription()
    {
        return description;
    }

    public void setSeed(long s)
    {
        seed = s;
    }

    public void setSeed(String s)
    {
        try
        {
            long l = Long.parseLong(s.trim());
            System.out.println("long l = " + l);
        }
        catch (NumberFormatException nfe)
        {
            System.out.println("NumberFormatException: " + nfe.getMessage());
        }
    }

    public void setName(String val)
    {
        name = val;
    }

    public void setDescription(String val)
    {
        description = val;
    }

    public String toString()
    {
        return name;
    }
}
